﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Controls.DataVisualization.Charting;
using System.Data.SqlClient;
using System.Data;

namespace luanvanFinal
{
    /// <summary>
    /// Interaction logic for wdProgress.xaml
    /// </summary>
    public partial class wdProgress : Window
    {
        private int idStage;
        
        public wdProgress()
        {
            InitializeComponent();            
            
        }
        public int IdStage
        {
            get { return idStage; }
            set { idStage = value; }
        }
        
        public void loadProject()
        {
            String strSQL = "select title from stage where Id='"+idStage+"'";
            clsStage stage = new clsStage();
            DataTable dt = stage.getDataStage(strSQL);
            if (dt != null)
            {
                tbStage.Text = dt.Rows[0][0].ToString();
            }
        }

        private void LoadLineChartData1(int id)
        {           
            String SQL = "select * from stageDetail where idStage = '" + id + "'";
            clsStageDetail stageDetail = new clsStageDetail();
            DataTable dt = stageDetail.getDataStageDetail(SQL);
            if (dt != null)
            {
                var list = new List<KeyValuePair<string, float>>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    list.Add(new KeyValuePair<string, float>(dt.Rows[i][1].ToString(), float.Parse(dt.Rows[i][4].ToString()) ));
                }
                ((ColumnSeries)mcChart.Series[0]).ItemsSource = list;
            }

            /*
            DataTable dt = progress.getDataProject(SQL);     
              ((BarSeries)mcChart.Series[0]).ItemsSource =
                    new KeyValuePair<String, int>[]{                    
                    new KeyValuePair<String, int>("Stage 1", 0),
                    new KeyValuePair<String, int>("Stage 2", 80),
                    new KeyValuePair<String, int>("Stage 3", 90),
                    new KeyValuePair<String, int>("Stage 4", 70),
                    };  */            
        }
       
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
           

        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {           
            
            loadProject();             
            
            LoadLineChartData1(IdStage);
        }
    }
}
